package com.mfcxy.entity;

import java.util.ArrayList;
import java.util.List;

import org.springframework.format.number.CurrencyStyleFormatter;

import com.mfcxy.exception.CustomException;

/**
 * 权限类
 * 
 * @author mfcxy
 *
 */
public class Permissions {
	private int id;
	private String name;
	private String codeorurl = "";
	private int pid;
	private String path;
	private int sort;
	private boolean checked = false; // 标记权限是否选中

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCodeorurl() {
		return codeorurl;
	}

	public void setCodeorurl(String codeorurl) {
		this.codeorurl = codeorurl;
	}

	public int getPid() {
		return pid;
	}

	public void setPid(int pid) {
		this.pid = pid;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public int getSort() {
		return sort;
	}

	public void setSort(int sort) {
		this.sort = sort;
	}

	/**
	 * 新增验证
	 * 
	 * @throws CustomException
	 */
	public void checkSave() throws CustomException {
		List<String> msglist = new ArrayList<>();
		if (name == null || name.trim().equals("")) {
			msglist.add("权限名称不能为空");
		}

		/*
		 * if(codeorurl == null || codeorurl.trim().equals("")) {
		 * msglist.add("权限资源不能为空"); }
		 */

		if (msglist.size() > 0) {
			throw new CustomException(msglist.toString());
		}
	}

	public boolean isChecked() {
		return checked;
	}

	public void setChecked(boolean checked) {
		this.checked = checked;
	}

	@Override
	public String toString() {
		return "Permissions [id=" + id + ", name=" + name + ", codeorurl=" + codeorurl + ", pid=" + pid + ", path="
				+ path + ", sort=" + sort + ", checked=" + checked + "]";
	}

}
